//
//  CardViewController.m
//  Lextra Junior ueb IT
//
//  Created by Dirk Lieder on 30.05.11.
//  Copyright 2011 Phosphon. All rights reserved.
//

#import "WimmelOverlayViewController.h"
#import "AsyncImageView.h"

#import "WimmelViewController.h"

@implementation WimmelOverlayViewController

@synthesize myLabel1,myLabel2;
@synthesize myRahmen;
@synthesize myButton;
@synthesize myCloseButton;
@synthesize myCloseButton2;

NSDictionary *myArray;


- (void)setDelegate:(id)new_delegate{
    Delegate = new_delegate;
    
}

- (void) showInfo:(NSDictionary *)myPoindInfo pos:(CGPoint)newOffset portrait:(BOOL)IsPortrait{
    //___NGUYEN_HUY_SON___
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    {
        CGPoint offsetIpad;
        if (IsPortrait == FALSE)
        {
            offsetIpad.x = newOffset.x + 32;
            offsetIpad.y = newOffset.y;
        }
        else        
        {
            offsetIpad.x = newOffset.x + 65;
            offsetIpad.y = newOffset.y + 94;
        }
        myButton.center = offsetIpad;
    }
    else
    {
        myButton.center = newOffset;
    }
    //___END_NGUYEN_HUY_SON___
    if(myButton.center.y <235){
        myCloseButton.center = CGPointMake (myCloseButton.center.x,myButton.center.y+50);
        myRahmen.center = CGPointMake (myRahmen.center.x,myButton.center.y+50+30);
        myLabel1.center = CGPointMake (myLabel1.center.x,myButton.center.y+50+20);
        myLabel2.center = CGPointMake (myLabel2.center.x,myButton.center.y+50+39);
    } else {
        myCloseButton.center = CGPointMake (myCloseButton.center.x,myButton.center.y-100);
        myRahmen.center = CGPointMake (myRahmen.center.x,myButton.center.y-100+30);
        myLabel1.center = CGPointMake (myLabel1.center.x,myButton.center.y-100+20);
        myLabel2.center = CGPointMake (myLabel2.center.x,myButton.center.y-100+39);
    }
    myArray = myPoindInfo;
    //Memory__ERROR_USUALY_SEPTEMBER_30_2011---> thuong xuyen bi bug__NGUYEN_HUY_SON_BUG
    NSMutableString *tmpString1 = [[NSMutableString alloc] initWithString:[myArray objectForKey:@"artikel"]];
    
    if([tmpString1 length] > 0){
        if(![tmpString1 hasSuffix:@"'"]){
            [tmpString1 appendString:@" "];
        }
    }
    if([[myArray objectForKey:@"origFR"] length] !=0){
        [tmpString1 appendString:[myArray objectForKey:@"origFR"]];    
    } else {
        [tmpString1 appendString:[myArray objectForKey:@"bezeichnungFR"]];    
    }
    
    
    NSMutableString *tmpString2;
    if([[myArray objectForKey:@"origDE"] length] !=0){
        tmpString2 = [[NSMutableString alloc] initWithString:[myArray objectForKey:@"origDE"]];
    } else {
        tmpString2 = [[NSMutableString alloc] initWithString:[myArray objectForKey:@"bezeichnungDE"]];
    }
    
    myLabel1.text = tmpString1;
    myLabel2.text = tmpString2;
    
    [tmpString1 release];
    [tmpString2 release];
    
}

- (IBAction) play:(id)sender{
    [Delegate playIt];
}

- (IBAction) close:(id)sender{
    [Delegate closePopup];
    
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    //[bigScrollView release];
    
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    {
        return YES;
    }
    else
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
}

@end
